package gps.monitor.jt809server.protocol.codec;

import gps.monitor.jt809server.entity.DownPlatformAccount;
import gps.monitor.jt809server.protocol.Jt809ParseException;
import gps.monitor.jt809server.protocol.model.AbstractJt809Message;
import gps.monitor.jt809server.protocol.model.Jt809Message1001;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import lombok.Data;

/**
 * @author cyq
 * @date 2021/11/7
 * @desc talk is cheep,show me the code
 */
@Data
public class Jt809Handler1001 implements IJt809Handler {

    @Override
    public AbstractJt809Message read(ByteBuf byteBuf, DownPlatformAccount account)  throws Jt809ParseException {
        Jt809Message1001 message1001 = new Jt809Message1001();
        message1001.setHeader(readGeneralHeader(byteBuf));
        message1001.setUserId(Long.valueOf(ByteBufUtil.hexDump(byteBuf.readBytes(4)),16));

        return message1001;
    }
}
